{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "eafa2358-4376-4538-8016-9208392dec71",
   "metadata": {},
   "source": [
    "### 1.数据预处理"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "46547fe3-44bc-49c5-bc85-008d7be1a222",
   "metadata": {},
   "outputs": [],
   "source": [
    "fen = open(\"train.tags.zh-en.en\", encoding=\"utf-8\")\n",
    "fzh = open(\"train.tags.zh-en.zh\", encoding=\"utf-8\")\n",
    "en_zh = []"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "18b73f71-d57c-4e69-9bf1-aa6065679c6a",
   "metadata": {},
   "outputs": [],
   "source": [
    "while True:\n",
    "    lz = fzh.readline()\n",
    "    le = fen.readline()\n",
    "    \n",
    "    if not lz:\n",
    "        assert not le\n",
    "        break\n",
    "    lz, le = lz.srtip(), le.strip()\n",
    "    \n",
    "    #解析文件各部分\n",
    "    if lz.startwith(\"<url>\"):\n",
    "        assert le.startswith(\"<url>\")\n",
    "        lz = fzh.readline()\n",
    "        le = fen.readline()\n",
    "        \n",
    "        #关键词\n",
    "        assert lz.startswith(\"<keywords>\")\n",
    "        assert le.startswith(\"<keywords>\")\n",
    "        lz = fzh.readline()\n",
    "        le = fen.readline()\n",
    "        \n",
    "        #演讲人\n",
    "        assert lz.startswith(\"<speaker>\")\n",
    "        assert le.startswith(\"<speaker>\")\n",
    "        lz = fzh.readline()\n",
    "        le = fen.readline()\n",
    "        \n",
    "        #演讲ID\n",
    "        assert lz.startswith(\"<talkid>\")\n",
    "        assert le.startswith(\"<talkid>\")\n",
    "        lz = fzh.readline()\n",
    "        le = fen.readline()\n",
    "        \n",
    "        #标题\n",
    "        assert lz.startswith(\"<title>\")\n",
    "        assert le.startswith(\"<title>\")\n",
    "        lz = fzh.readline()\n",
    "        le = fen.readline()\n",
    "        \n",
    "        #描述\n",
    "        assert lz.startswith(\"<description>\")\n",
    "        assert le.startswith(\"<description>\")\n",
    "        lz = fzh.readline()\n",
    "        le = fen.readline()\n",
    "        "
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.9.12"
  },
  "widgets": {
   "application/vnd.jupyter.widget-state+json": {
    "state": {},
    "version_major": 2,
    "version_minor": 0
   }
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
